#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
long long n,t,a[N],ans,r;bool f[N];
void dfs(int x){
    int t=ans;
    for(int i=x-1;i>=1;i--){
        if(f[i]==f[x]){
            if(a[i]==a[x]) ans+=a[i];
            break;
        }
    }
    if(x==n){
        r=max(ans,r);
        return;
    }
    f[x+1]=0;
    dfs(x+1);
    f[x+1]=1;
    dfs(x+1);
    ans=t;
}
int main(){freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n;r=0,ans=0;
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        dfs(0);printf("%lld\n",r);
    }
    fclose(stdin);fclose(stdout);
    return 0;
}
